#include "CDiamondqueue.h"

CDiamondqueue::CDiamondqueue(QObject *parent)
	: QObject(parent)
{}

CDiamondqueue::~CDiamondqueue()
{}

void CDiamondqueue::enqueue(DiamondData data)
{
	m_mutex.lock();
	m_queue.enqueue(data);
	m_mutex.unlock();
}

DiamondData CDiamondqueue::dequeue()
{
	m_mutex.lock();
	if (!m_queue.empty())
	{
		DiamondData data = m_queue.dequeue();
		m_mutex.unlock();
		return data;
	}
	m_mutex.unlock();
	return DiamondData();
}

bool CDiamondqueue::isEmpty()
{
	m_mutex.lock();
	if (m_queue.empty())
	{
		m_mutex.unlock();
		return true;
	}
	m_mutex.unlock();
	return false;
}

int CDiamondqueue::seize()
{
	return   m_queue.size();
}
